package org.acghub.mtdb.core;

import org.acghub.mtdb.core.cache.ConcurrentTableCache;
import org.acghub.mtdb.core.cache.LRUTableCache;

/**
 * @author zhouhe
 */

public enum TableCacheType {

    LRU {
        @Override
        public <K, V> TableCache<K, V> newInstance() {
            return new LRUTableCache<>();
        }
    },

    CONCURRENT {
        @Override
        public <K, V> TableCache<K, V> newInstance() {
            return new ConcurrentTableCache<>();
        }
    },
    ;


    static TableCacheType of(String type) {
        for (TableCacheType value : values()) {
            if (value.name().equalsIgnoreCase(type)) {
                return value;
            }
        }
        return null;
    }

    public abstract <K, V> TableCache<K, V> newInstance();
}
